﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CreatIcon
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string dir = this.textBox1.Text;
            DirectoryInfo mydir = new DirectoryInfo(dir);
            int i = 1;
            StreamWriter sw = new StreamWriter(@"D:\icon.css");
            StreamWriter swlog = new StreamWriter(@"D:\icon-log.txt");
            foreach (FileSystemInfo fsi in mydir.GetFileSystemInfos())
            {
                if (fsi is FileInfo)
                {
                    FileInfo fi = (FileInfo)fsi;
                    string x = System.IO.Path.GetDirectoryName(fi.FullName);
                    Console.WriteLine(x);
                    string s = System.IO.Path.GetExtension(fi.FullName);
                    string y = System.IO.Path.GetFileNameWithoutExtension(fi.FullName);
                    string fileName = System.IO.Path.GetFileName(fi.FullName);
                    if (s == ".png")
                    {
                        i++;
                       
                        sw.WriteLine(@".icon-"+y+@"{background:url('icons/"+y +@".png') no-repeat;}");
                       
                        swlog.WriteLine(@"第" +i + @"项，" + fileName);
                       
                    }
                }

            }
            sw.Close();
            sw.Dispose();
            swlog.Close();
            swlog.Dispose();
        }
    }
}
